<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>


<body>
    <button onclick="getTeachers()">获取数据</button>
</body>
<!-- js加载是阻塞代码执行的 -->
<script type="text/javascript">
    function test(data) {
        console.log(data)
    }

    function getTeachers(url) {
        // 创建script元素
        const script = document.createElement('script')
        // 指定script的src属性
        script.src = 'http://192.168.1.122:8081/jsonp?callback=test'
        // 将script元素添加到body中触发脚本加载
        document.body.appendChild(script)
        // script标签加载完毕后移除该标签
        script.onload = () => {
            script.remove()
        }

    }
</script>

</html>